Blog

Curt Gratz

February 01, 2013

Spread the word


Share your thoughts

 


ColdBox-CacheBack

A cool annotation based Caching Aspect for WireBox/ColdBox that provides caching without blocking requests during refresh

This interceptor will inspect objects for the 'cacheBack' annotation and if found, it will wrap it in a thread creating cache. This allows the function to be cached without waiting for it to refresh. Inspiration from God and from this library. http://django-cacheback.readthedocs.org/en/latest/

This aspect is a self binding
aspect for WireBox that registers itself using the annotations below
You can control the refresh rate for your cache and the timeout in a number of ways
    1) You can add an annotation to your method called refreshRate and timeout
        ie function myFunction() cacheback refreshRate=120 timeout=240 {}
        This will set cache to refresh every 2 mins and timeout every 4 mins.
    2) You can add a settings to your coldbox config called cacheBack.  The setting will be a structure with
       keys of refreshRate and timeout
        cacheBack = {refreshRate=60,timeout=120}
        This will set cache to refresh every 60 secs and timeout every 120 secs.
    3) You can use our default timeouts which are a refresh rate 18 mins and a timeout of 20 mins
All refresh rates and timeouts are in seconds

To activate this aspect you will need to map it in your WireBox binder.  This can be done like below
mapAspect("cacheBack").to("model.aspects.cacheBack");
Then all you need to do is add the annotation cachback to your methods
myFunction() cacheback refreshRate=120 timeout=240 {}

Keep in mind like all things caching, testing and tuning is very important. This can be used in very specific scenarios when you want to keep cache refreshing, but don't want users to wait for the refresh.

The GitHub repo is available at https://github.com/gratzc/ColdBox-CacheBack

You can also download from our ForgeBox http://www.coldbox.org/forgebox/view/CacheBack

Hope you enjoy.

 

Add Your Comment

(1)

Feb 08, 2013 17:09:20 UTC

by Ken

Coolness!

Recent Entries

Mastering Events and Listeners in CBWIRE

Mastering Events and Listeners in CBWIRE

In CBWIRE, events and listeners are the backbone of building responsive, modular applications without relying heavily on JavaScript. This guide walks you through setting up and using CBWIRE events to create seamless interactions between components, from dispatching events in CFML and frontend templates to listening with Alpine.js and JavaScript. Learn how to make your applications feel dynamic and engaging by effortlessly connecting components. Whether you’re triggering events to update a dashboard or targeting specific parts of your app with dispatchTo, these techniques will empower you to create a modern, interactive CFML experience with ease.

Grant Copley
Grant Copley
November 11, 2024
10 Key Benefits of Hiring a Specialized ColdFusion Consulting Team

10 Key Benefits of Hiring a Specialized ColdFusion Consulting Team

ColdFusion remains a powerful and versatile platform for building dynamic web applications. However, keeping your ColdFusion environment optimized, secure, and scalable requires specialized expertise. Whether managing a long-standing ColdFusion application or planning new development projects, hiring a dedicated ColdFusion consulting and support team can be a game-changer for CTOs, CIOs, and developers. Here's why:

1. Expert Guidance on ColdFusion Web Development

...

Cristobal Escobar
Cristobal Escobar
November 08, 2024
ColdBox Free Tip 5 - Building Named Routes with a Struct

ColdBox Free Tip 5 - Building Named Routes with a Struct

**Did you know ColdBox provides flexible ways to build routes using structs?** In this tip, we’ll cover how to use the `event.buildLink()` and `event.route()` methods for named routes, a feature that’s especially handy when working with dynamic URLs.

Maria Jose Herrera
Maria Jose Herrera
November 07, 2024